<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2024/2/23
 * Time: 11:21
 */

namespace app\api\model;

class Address extends Base
{
    protected $hidden = ['addr_del', 'addr_time', 'addr_update_time'];

    /**
     * 多条查询
     * @param $where
     * @param $page
     * @return bool|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static function selectData($where = []){
        return self::where($where)
            ->where('addr_del', 1)
            ->order('addr_default asc, addr_time desc')
            ->select();
    }

    /**
     * 统计数量
     * @param $where
     * @return int|string
     * @throws \think\Exception
     */
    static function countData($where = []){
        return self::where($where)->where('addr_del', 1)->count();
    }

    /**
     * 单条查询
     * @param $where
     * @return array|bool|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static function findData($where = []){
        return self::where($where)->where('addr_del', 1)->find();
    }
}